package behavior.responsibility.stratum;

import behavior.responsibility.WarReport;

/**
 * 阶层抽象
 */
public abstract class AbstractStratum {

    /**
     * 责任链中的下一个元素
     */
    protected AbstractStratum nextStratum;

    protected WarReport warReport;

    protected Integer level;


    /**
     * 下一个执行者
     * @param nextStratum
     */
    public void setNextStratum(AbstractStratum nextStratum){
        this.nextStratum = nextStratum;
    }

    /**
     *  处理这个信息
     * @param warReport
     */
    public void handleMessage(WarReport warReport){
        Integer level = warReport.getLevel();
        if(level<= this.level){
            handle(warReport);
            return;
        }
        if (nextStratum != null){
            nextStratum.handleMessage(warReport);
        }
    }

    /**
     * 处理
     */
    abstract protected void handle(WarReport warReport);
}
